package model.entity;

import java.util.List;

import main.Log;
import model.entity.brain.Brain;
import model.entity.stats.StatSet;
import model.item.EquippedInventory;
import model.item.Inventory;
import model.map.Direction;
import model.map.Location;
import model.map.MovementType;
import model.map.World;
import model.resource.AvatarMount;
import utilities.*;

/**
 * 
 * This represents a self-moving NPC that can 
 * be mounted by an Avatar. 
 *
 */

public class MountableNPC extends NPC implements Mountable, Archiveable {


	public boolean mounted = false;
	public MountableNPC(String name, Direction direction, Location location, StatSet stats, 
			List<MovementType> movementTypes, Inventory inventory, 
			EquippedInventory equipment, Occupation occupation, Boolean sleeping, Brain brain){

		super(name, direction, location, stats, 
				movementTypes, inventory, 
				equipment, occupation, sleeping, brain);

	}

	public MountableNPC() {
		// TODO Auto-generated constructor stub
	}

	public void mount(Entity av){
		AvatarMount.getInstance().add(av, this);
		av.setLocation(location);
		mounted = true;
	}

	public void unmount(Entity av){
		AvatarMount.getInstance().remove(av);
		mounted = false;
	}

	public boolean isMounted(){
		return mounted;
	}
	
	public Archive save() {
		Archive archive = super.save();
		
//		archive.putAttribute("mounted", Boolean.toString(this.mounted));
		
		return archive;
	}
	
	public void load(Archive archive) {
		super.load(archive);
		
//		this.mounted = Boolean.parseBoolean(archive.getAttribute("mounted"));
	}

}

